CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(LiveRelay)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

option(NOCRT "link crt static" ON)

if (MSVC)
    #warning 4251
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819 /wd4996 ")
	
    if (NOCRT)
		set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DWIN32 /MTd")
		set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DWIN32 /MT")
	endif()
	
	set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:NOREF /OPT:ICF")
	
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/lib)

    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/lib)
    
    if (MSVC90)
        add_definitions(-D_BIND_TO_CURRENT_VCLIBS_VERSION=1)
    endif()
else()
	#set(CMAKE_CXX_VISIBILITY_PRESET hidden)
	set(CMAKE_C_FLAGS "-fvisibility=hidden")
	set(CMAKE_CXX_FLAGS "-fvisibility=hidden")
endif()

set(PROJECT_ROOT ${PROJECT_SOURCE_DIR})
set(THIRD_PARTY ${PROJECT_ROOT}/third_party)
set(COMN_DIR ${PROJECT_ROOT}/comn)
SET(DIR_FFMPEG ${THIRD_PARTY}/ffmpeg)
SET(GLOOX_DIR ${THIRD_PARTY}/gloox-1.0.14)

if (CMAKE_HOST_WIN32)
    set(LIB_PLATFORM ws2_32 )
else()
    set(LIB_PLATFORM pthread rt)
endif()

SET(LIB_FFMPEG avutil avcodec avformat swresample)
if(CMAKE_HOST_WIN32)
else()
	SET(LIB_FFMPEG avutil-55 avcodec-57 avformat-57 swresample-2)
endif()

if(WIN32)
	SET(GLOOX_LIBS gloox)
else()
	SET(GLOOX_LIBS gloox resolv)
endif()

ADD_SUBDIRECTORY(comn)

ADD_SUBDIRECTORY(third_party)

ADD_SUBDIRECTORY(RtpCaster)
ADD_SUBDIRECTORY(LiveDevice)
ADD_SUBDIRECTORY(RtspCaster)
ADD_SUBDIRECTORY(RtspRelay)
ADD_SUBDIRECTORY(LiveRelayServer)

if(CMAKE_TOOLCHAIN_FILE)
	# cross compiling
else()
	ADD_SUBDIRECTORY(DemoCaster)
	ADD_SUBDIRECTORY(DemoDevice)
	ADD_SUBDIRECTORY(DemoRtspCaster)
	
endif()

if(WIN32)
	ADD_SUBDIRECTORY(DemoOpus)
endif ()

#ADD_SUBDIRECTORY(DemoLoop)

#ADD_SUBDIRECTORY(DemoRelay)

